package com.yx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yx.pojo.Dept;
import com.yx.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface EmpMapper extends BaseMapper<Emp> {
//    /**
//     * 分页查询全部员工信息
//     * @return
//     */
//    @Select("select count(*) fhuoqurom emp")
//    public Long count();
    //获取列表数据
//    @Select("select * from emp limit #{start},#{pageSize}")
//    public List<Emp> page(Integer start, Integer pageSize);

//    /**
//     * 员工信息查询，利用pagehelp插件
//     * @return
//     */
//    @Select("select * from emp")
    public List<Emp> list(String name, Short gender, LocalDateTime begin, LocalDateTime end);


    /**
     *批量删除
     * @param ids
     */
    void delete(List<Integer> ids);

    /**
     * 新增员工
     * @param emp
     */
    /*@Insert("insert into emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time) " +
            "values (#{username}, #{name}, #{gender}, #{image}, #{job}, #{entrydate}, #{deptId}, #{createTime}, #{updateTime})")
    void insert(Emp emp);*/

    /**
     * 根据id查询员工信息
     * @param id
     * @return
     */
    @Select("select * from emp where id = #{id}")
    Emp getById(Integer id);

    /**
     * 更新员工信息
     * @param emp
     */
    void update(Emp emp);

    /**
     * 员工登录
     * @param emp
     * @return
     */
    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp getUserNameAndPassword(Emp emp);

@Delete("delete from emp where dept_id = #{deptId}")
    void deleteByDeptId(Integer deptId);
}
